package com.admin.controller;


import com.admin.service.SysAgreementService;
import com.fegin.bean.admin.SysAgreement;
import com.util.Respons.ResponseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

/**
 * <p>
 * 系统协议 前端控制器
 * </p>
 *
 * @author 张子艺
 * @since 2019-01-22
 */
@Controller
@RequestMapping("/admin/sysAgreement")
public class SysAgreementController {
    @Autowired
    SysAgreementService sysAgreementService;


    /**
     * 协议保存
     *
     * @return
     */
    @RequestMapping(value = "/insert" )
    @ResponseBody
    public Map<String,Object> insert(@RequestBody SysAgreement sysAgreement) {
        if(sysAgreementService.saveOrUpdate(sysAgreement)){
            return ResponseUtil.getSuccessMap();
        }else{
            return ResponseUtil.getNotNormalMap();
        }

    }



    /**
     * 协议查询
     *
     * @return
     */
    @RequestMapping(value = "/findAgreement")
    @ResponseBody
    public Map<String, Object> findAgreement( ) {
        return ResponseUtil.getSuccessMap(sysAgreementService.listByMap(new HashMap<>()),"成功");
    }
}
